package com.ruoyi.healthCard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.healthCard.domain.TBizReport;
import com.ruoyi.healthCard.service.ITBizReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检报告Controller
 * 
 * @author ruoyi
 * @date 2025-06-27
 */
@RestController
@RequestMapping("/health/report")
public class TBizReportController extends BaseController
{
    @Autowired
    private ITBizReportService tBizReportService;

    /**
     * 查询体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('health:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBizReport tBizReport)
    {
        startPage();
        List<TBizReport> list = tBizReportService.selectTBizReportList(tBizReport);
        return getDataTable(list);
    }

    /**
     * 导出体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('health:report:export')")
    @Log(title = "体检报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBizReport tBizReport)
    {
        List<TBizReport> list = tBizReportService.selectTBizReportList(tBizReport);
        ExcelUtil<TBizReport> util = new ExcelUtil<TBizReport>(TBizReport.class);
        util.exportExcel(response, list, "体检报告数据");
    }

    /**
     * 获取体检报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:report:query')")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return success(tBizReportService.selectTBizReportByReportId(reportId));
    }

    /**
     * 新增体检报告
     */
    @PreAuthorize("@ss.hasPermi('health:report:add')")
    @Log(title = "体检报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBizReport tBizReport)
    {
        return toAjax(tBizReportService.insertTBizReport(tBizReport));
    }

    /**
     * 修改体检报告
     */
    @PreAuthorize("@ss.hasPermi('health:report:edit')")
    @Log(title = "体检报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBizReport tBizReport)
    {
        return toAjax(tBizReportService.updateTBizReport(tBizReport));
    }

    /**
     * 删除体检报告
     */
    @PreAuthorize("@ss.hasPermi('health:report:remove')")
    @Log(title = "体检报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(tBizReportService.deleteTBizReportByReportIds(reportIds));
    }
}
